/**
 * ajaxURL.
 */
function ajaxURL(url) {
	/*$("#li_home").removeClass("active");*/
	
	$.ajax({
        url: url,
        data: null,
        type: "POST",
         
        beforeSend: function(xhr) {
            xhr.setRequestHeader("Accept", "application/json");
            xhr.setRequestHeader("Content-Type", "application/json");
        },
        success: function(data) {
    		$( "#divConteudo" ).html( data );  
        }
    });
}

function ajaxJSON(url, json, success, error) {
	$.ajax({
		  type: "POST",
		  url: url,
		  async: false,
		  data: JSON.stringify(json),
		  beforeSend: function(xhr) {  
		        xhr.setRequestHeader("Accept", "application/json");  
		        xhr.setRequestHeader("Content-Type", "application/json");  
		  },
		  success: function(resultado){
			  success(resultado)
	
		  }, error  : function(xhr, textStatus, errorThrown) {
			  if (xhr.status !== 401) {
				  error(xhr.responseText, xhr.status);
			  }
		  }
	});
}

function ajaxPOST(url, form, success, error, finallySuccess) {
	var data = form.serializeArray();
	var isError = false;
	var jqxhr = $.post( url, data)
	  .done(function(resultado) {
		  success(resultado);
	  })
	  .fail(function(e) {
		  isError = true;
		  error(e.detailMessage);
	  }).always(function() {
		  if (!isError && finallySuccess != null) {
			finallySuccess();
		}
	  });
}

function success(resultado) {
	$("#divConteudo").html(resultado);  
}

function error (e) {
	alert(e);
}

function finallySuccess () {
	alert("finallySuccess");
}